package com.kefu.smartCall.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kefu.common.controller.AbstractBaseController;
import com.kefu.common.result.Result;
import com.kefu.common.result.ResultGenerator;
import com.kefu.smartCall.model.ScTaskCall;
import com.kefu.smartCall.model.ScTaskCallMsg;
import com.kefu.smartCall.service.ScTaskCallService;
import com.kefu.smartCall.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "大模型筛选拨打记录")
@RestController
@RequestMapping("smartCall/call")
public class ScTaskCallController extends AbstractBaseController {
    @Resource
    protected ScTaskCallService scTaskCallService;

    @PostMapping("/batchUpdateCall")
    @ApiOperation(value = "批量修改状态")
    public Result<List<String>> batchUpdateCall(@Validated @RequestBody ScTaskCallBatchUpdateVo search) {
        List<String> result = scTaskCallService.batchUpdateCall(search);
        return ResultGenerator.genSuccessResult(result);
    }

    @PostMapping("/queryTaskCallList")
    @ApiOperation(value = "查询外呼任务拨打数据")
    public Result<Page<ScTaskCall>> list(@Validated @RequestBody ScTaskCallSearchVo search) {
        Page<ScTaskCall> page = scTaskCallService.queryTaskCallList(search);
        return ResultGenerator.genSuccessResult(page);
    }

    @PostMapping("/queryTaskCallMsg")
    @ApiOperation(value = "查询外呼任务数据聊天记录")
    public Result<List<ScTaskCallMsg>> queryTaskCallMsg(@Validated @RequestBody QueryTaskCallMsgVo search) {
        return ResultGenerator.genSuccessResult(scTaskCallService.queryTaskCallMsg(search));
    }

    @PostMapping("/queryTaskStat")
    @ApiOperation("查询任务统计")
    public Result<ScTaskStatVo> queryTaskStat(@Validated @RequestBody ScTaskDetailVo detailVo) {
        return ResultGenerator.genSuccessResult(scTaskCallService.queryTaskStat(detailVo.getTaskId()));
    }
}
